package com.linpq.road.controller;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.linpq.common.annotation.Log;
import com.linpq.common.enums.BusinessType;
import com.linpq.road.domain.RdRoadLinearity;
import com.linpq.road.service.RdRoadLinearityService;
import com.linpq.common.core.controller.BaseController;
import com.linpq.common.core.domain.AjaxResult;
import com.linpq.common.utils.poi.ExcelUtil;
import com.linpq.common.core.page.TableDataInfo;

/**
 * 路面线性Controller
 *
 * @author linpq
 * @date 2021-07-29
 */
@Controller
@RequestMapping("/road/road_linearity")
public class RdRoadLinearityController extends BaseController {
    private String prefix = "road/road_linearity";

    @Autowired
    private RdRoadLinearityService rdRoadLinearityService;

    @RequiresPermissions("road:road_linearity:view")
    @GetMapping()
    public String road_linearity() {
        return prefix + "/road_linearity";
    }

    /**
     * 查询路面线性列表
     */
    @RequiresPermissions("road:road_linearity:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RdRoadLinearity rdRoadLinearity) {
        startPage();
        List<RdRoadLinearity> list = rdRoadLinearityService.selectRdRoadLinearityList(rdRoadLinearity);
        return getDataTable(list);
    }

    /**
     * 导出路面线性列表
     */
    @RequiresPermissions("road:road_linearity:export")
    @Log(title = "路面线性", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RdRoadLinearity rdRoadLinearity) {
        List<RdRoadLinearity> list = rdRoadLinearityService.selectRdRoadLinearityList(rdRoadLinearity);
        ExcelUtil<RdRoadLinearity> util = new ExcelUtil<RdRoadLinearity>(RdRoadLinearity. class);
        return util.exportExcel(list, "road_linearity");
    }

    /**
     * 新增路面线性
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存路面线性
     */
    @RequiresPermissions("road:road_linearity:add")
    @Log(title = "路面线性", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RdRoadLinearity rdRoadLinearity) {
        return toAjax(rdRoadLinearityService.insertRdRoadLinearity(rdRoadLinearity));
    }

    /**
     * 修改路面线性
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap) {
        RdRoadLinearity rdRoadLinearity =rdRoadLinearityService.selectRdRoadLinearityById(id);
        mmap.put("rdRoadLinearity", rdRoadLinearity);
        return prefix + "/edit";
    }

    /**
     * 修改保存路面线性
     */
    @RequiresPermissions("road:road_linearity:edit")
    @Log(title = "路面线性", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RdRoadLinearity rdRoadLinearity) {
        return toAjax(rdRoadLinearityService.updateRdRoadLinearity(rdRoadLinearity));
    }

    /**
     * 删除路面线性
     */
    @RequiresPermissions("road:road_linearity:remove")
    @Log(title = "路面线性", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(rdRoadLinearityService.deleteRdRoadLinearityByIds(ids));
    }
}
